package com.petRescueCenter.demo.voluntary.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.petRescueCenter.demo.common.enumPackage.LockedEmun;
import com.petRescueCenter.demo.img.entity.Img;

@Entity
@Table(name = "t_voluntary")
public class Voluntary {

	private Long id;
	private Set<Img> img;
	private String mail;
	private String name;
	private String content;
	private Date createTime;
	private String title;
	private Date activityTimeStart;
	private Date activityTimeEnd;
	private Set<UserVoluntary> uservoluntary;
	private Date endTime;
	private String tel;
	private LockedEmun locked;
	private LockedEmun state;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public LockedEmun getLocked() {
		return locked;
	}

	public String getMail() {
		return mail;
	}

	public LockedEmun getState() {
		return state;
	}

	public void setState(LockedEmun state) {
		this.state = state;
	}

	public void setMail(String mail) {
		this.mail = mail;
	}

	public void setLocked(LockedEmun locked) {
		this.locked = locked;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public String getContent() {
		return content;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
	public Date getCreateTime() {
		return createTime;
	}

	public String getTitle() {
		return title;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
	public Date getEndTime() {
		return endTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
	public Date getActivityTimeStart() {
		return activityTimeStart;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@JsonFormat(pattern = "yyyy/MM/dd HH:mm:ss", timezone = "GMT+8")
	public Date getActivityTimeEnd() {
		return activityTimeEnd;
	}

	public void setActivityTimeStart(Date activityTimeStart) {
		this.activityTimeStart = activityTimeStart;
	}

	public void setActivityTimeEnd(Date activityTimeEnd) {
		this.activityTimeEnd = activityTimeEnd;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@OneToMany(mappedBy = "voluntary", cascade = CascadeType.ALL)
	public Set<UserVoluntary> getUservoluntary() {
		return uservoluntary;
	}

	public void setUservoluntary(Set<UserVoluntary> uservoluntary) {
		this.uservoluntary = uservoluntary;
	}

	@OneToMany(fetch = FetchType.EAGER)
	@JoinColumn(name = "voluntaryId")
	public Set<Img> getImg() {
		return img;
	}

	public void setImg(Set<Img> img) {
		this.img = img;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public String toString() {
		return "Voluntary [id=" + id + ", img=" + img + ", name=" + name + ", content=" + content + ", createTime="
				+ createTime + ", title=" + title + ", activityTimeStart=" + activityTimeStart + ", activityTimeEnd="
				+ activityTimeEnd + ",  endTime=" + endTime + ", tel=" + tel + "]";
	}

}
